    //创建和初始化地图函数：
    function initMap(){
      createMap();//创建地图
      setMapEvent();//设置地图事件
      addMapControl();//向地图添加控件
      addMapOverlay();//向地图添加覆盖物
    }


    function createMap(){ 
      map = new BMap.Map("map"); 
      map.centerAndZoom(new BMap.Point(121.446434,31.299197),16);
    }
    function setMapEvent(){
      map.enableScrollWheelZoom();
      map.enableKeyboard();
      map.enableDragging();
      map.enableDoubleClickZoom()
    }
    function addClickHandler(target,window){
      target.addEventListener("click",function(){
        target.openInfoWindow(window);
      });
    }

  // 创建标注点并添加到地图中
  

  function addMapOverlay(){
var points = [  
{"lng":121.446434,"lat":31.299197,"url":"http://www.xxoa.top","id":'公司位置',"name":"云图总部"},  

]; 

    for(var i=0, pointsLen = points.length; i<pointsLen; i++) {

      var point = new BMap.Point(points[i].lng, points[i].lat);
      var marker = new BMap.Marker(point);
      map.addOverlay(marker);



      marker.addEventListener("click",
                function() {
                showInfo(this,points);
            });
      // (function() {
      //       var thePoint = points;
      //       marker.addEventListener("click",
      //           function() {
      //           showInfo(this,thePoint);
      //       });
      //    })(); 
    }
}


function showInfo(thisMarker,point) {
    //获取点的信息
    var sContent = 
    '<ul style="margin:0 0 5px 0;padding:0.2em 0">'  
    +'<li style="line-height: 26px;font-size: 15px;">'  
    +'<span style="width: 50px;display: inline-block;">id：</span>' +point[0].id + '</li>'  
    +'<li style="line-height: 26px;font-size: 15px;">'
    +'<span style="width: 50px;display: inline-block;">名称：</span>' + point[0].name + '</li>'  
    +'<li style="line-height: 26px;font-size: 15px;"><span style="width: 50px;display: inline-block;">查看：</span><a href="'+point[0].url+'">详情</a></li>'  
    +'</ul>';
    var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
    thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
}

    //向地图添加控件
    function addMapControl(){
      var scaleControl = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
      scaleControl.setUnit(BMAP_UNIT_IMPERIAL);
      map.addControl(scaleControl);
      var navControl = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
      map.addControl(navControl);
      var overviewControl = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:true});
      map.addControl(overviewControl);
    }
    var map;
      initMap();

